package com.gem.day15.exercise;

/**
 * 定义两条线程,一条线程负责输出数字,另一条线程负责输出字母,
 * 要求两条线程同时启动,打印出如下效果:
 * 12A34B56C78D...5152Z
 */
public class Exercise1 {
	public static void main(String[] args) {
		Thread t1 = new NumberThread();
		Thread t2 = new LetterThread();
		t1.start();
		try {
			Thread.sleep(200);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		t2.start();
	}
}

//字母线程
class LetterThread extends Thread {
	@Override
	public void run() {
		for (char c = 'A'; c <= 'Z'; c++) {
			System.out.print(c);
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}

//数字线程
class NumberThread extends Thread {
	@Override
	public void run() {
		for (int i = 1; i <= 26; i++) {
			System.out.print(i * 2 - 1);
			System.out.print(i * 2);
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
